
public class mainclass {
	public int fieldofparent;
	public mainclass (int v){
		fieldofparent = v;
	}
	public static void main(String[] args)
	{
		mainclass oparent = new mainclass(11);
		child ochild = new child(8,20);
		
		System.out.println(oparent.fieldofparent);// defaulf
		System.out.println(ochild.fieldofchild);
		System.out.println(ochild.fieldofparent);//ke thua tu cha xuong
		
		grandchild ograndchild = new grandchild(100,1000,1000000);
		
		System.out.println(ograndchild.fieldofparent);
		System.out.println(ograndchild.fieldofchild);
		System.out.println(ograndchild.fieldofgrandchild);
	}
}

class child extends mainclass{
	public int fieldofchild;
	public child(int valforparent , int valforchild)
	{
		super(valforparent);
		fieldofchild = valforchild;
	}
}


class grandchild extends child{
	public int fieldofgrandchild;
	public grandchild(int valparent, int valchild, int valgrandchild)
	{
		super(valparent, valchild);
		fieldofgrandchild = valgrandchild;
	}
}

